package br.com.albatroz.dao;

import java.util.List;

public interface IDao<T> {

    /**
     * Get all entities of type T.
     *
     * @return a list of entity objects.
     */
    List<T> findAll();

    /**
     * Find entity by the id.
     *
     * @param value the id.
     * @return a entity or null if no entity was found.
     */
    T findById(long value);

    /**
     * Stores a entity in the db.
     *
     * @param entity the entity.
     */
    void store(T entity);

    /**
     * Attaches (and stores) an object to the session.
     *
     * @param entity the object to attach.
     */
    void merge(T entity);

    /**
     * Deletes a entity.
     *
     * @param entity the entity.
     */
    void delete(T entity);

    /**
     * Helper for unit test. Use with care.
     */
    void deleteAll();

    /**
     * Flushes.
     */
    void flush();
}
